PhD

The LaTeX sources of my Ph.D. thesis
git clone https://esimon.eu/repos/PhD.git
Log | Files | Refs | README | LICENSE

epgnn sentence representation.tex (2813B)


      1 \begin{tikzpicture}[
      2 		word after/.style={right=0.9mm of #1, inner sep=0},
      3 		token after/.style={right=0mm of #1, inner sep=0},
      4 		vector/.style={draw, anchor=south, rectangle, minimum width=1.5mm, inner sep=0mm, minimum height=6mm},
      5 		row vector/.style={vector, minimum height=1.5mm, minimum width=6mm},
      6 	]
      7 	\node[inner sep=0]       (cls) {\strut \textsc{cls}};
      8 	\node[word after=cls]    (be1) {\strut \texttt{<e1>}};
      9 	\node[word after=be1] (jeremy) {\strut Jeremy};
     10 	\node[word after=jeremy] (ben) {\strut Ben};
     11 	\node[token after=ben]  (tham) {\strut tham};
     12 	\node[word after=tham]   (ee1) {\strut \texttt{</e1>}};
     13 	\node[word after=ee1]    (was) {\strut was};
     14 	\node[word after=was]   (born) {\strut born};
     15 	\node[word after=born]    (in) {\strut in};
     16 	\node[word after=in]     (be2) {\strut \texttt{<e2>}};
     17 	\node[word after=be2] (london) {\strut London};
     18 	\node[word after=london] (ee2) {\strut \texttt{</e2>}};
     19 	\node[word after=ee2] (period) {\strut .};
     20 	\node[word after=period] (eos) {\strut \textsc{eos}};
     21 
     22 	\coordinate (bertsw) at ($(cls.north west) + (0,5mm)$);
     23 	\coordinate (bertne) at ($(eos.north east) + (0,15mm)$);
     24 	\node[draw, rectangle, inner sep=0mm, fit=(bertsw) (bertne)] (bert) {};
     25 	\node[anchor=center] at (bert.center) {\large\textsc{bert}};
     26 
     27 	\foreach \w/\focus in {
     28 		cls/1,
     29 		be1/\transparencyDefault,
     30 		jeremy/1,
     31 		ben/1,
     32 		tham/1,
     33 		ee1/\transparencyDefault,
     34 		was/\transparencyDefault,
     35 		born/\transparencyDefault,
     36 		in/\transparencyDefault,
     37 		be2/\transparencyDefault,
     38 		london/1,
     39 		ee2/\transparencyDefault,
     40 		period/\transparencyDefault,
     41 		eos/\transparencyDefault
     42 	}{
     43 		\begin{scope}[opacity=\focus]
     44 			\node[vector] (v\w) at ($(\w.north) + (0, 2cm)$) {};
     45 			\draw[arrow] (\w) -- (\w|-bert.south);
     46 			\draw[arrow] (\w|-bert.north) -- (v\w);
     47 		\end{scope}
     48 	}
     49 
     50 	\coordinate (mean1c) at ($(vjeremy.north west)!0.5!(vtham.north east)$);
     51 	\node[draw, rectangle, anchor=south] (mean1) at ($(mean1c) + (0,5mm)$) {Mean pooling};
     52 	\draw[arrow] (vjeremy) -- (vjeremy|-mean1.south);
     53 	\draw[arrow] (vben) -- (vben|-mean1.south);
     54 	\draw[arrow] (vtham) -- (vtham|-mean1.south);
     55 
     56 	\node[draw, rectangle, anchor=south] (mean2) at ($(vlondon.north) + (0,5mm)$) {Mean pooling};
     57 	\draw[arrow] (vlondon) -- (mean2);
     58 
     59 	\coordinate (ftop) at ($(mean1.north) + (0,6mm)$);
     60 	\node[row vector] (re1) at (ftop-|bert) {};
     61 	\node[row vector,right=0mm of re1] (re2) {};
     62 	\node[row vector,left=0mm of re1] (rcls) {};
     63 
     64 	\coordinate (fmid) at ($(mean1.north) + (0,1.5mm)$);
     65 	\coordinate (fmidplus) at ($(mean1.north) + (0,2.5mm)$);
     66 
     67 	\draw[arrow,rounded corners=1mm] (vcls) -- (vcls|-fmidplus) -- (rcls|-fmidplus) -- (rcls);
     68 	\draw[arrow,rounded corners=1mm] (mean1) -- (mean1|-fmid) -- (re1|-fmid) -- (re1);
     69 	\draw[arrow,rounded corners=1mm] (mean2) -- (mean2|-fmid) -- (re2|-fmid) -- (re2);
     70 \end{tikzpicture}